/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Practica1.practica;

import Practica1.util.Vertex;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author miguel
 */
public class MyVertex<E> extends Vertex<E> {
    
    private ArrayList<Vertex<E>> neighbours;
    private int grade;
    private int ingrade;
    private int exgrade;
    
    
    
    public MyVertex(){
        super();
        neighbours = new ArrayList<>();
        grade = 0;
    }
    
    public MyVertex(E element){
        super(element);
        neighbours = new ArrayList<>();
        grade = 0;
    }
    
    public MyVertex(E element,int index){
        super(element,index);
        neighbours = new ArrayList<>();
        grade = 0;
    }
    

    @Override
    public List<Vertex<E>> getNeighboursList() {
        return neighbours;
    }

    @Override
    public Vertex<E> getNeighbour(int i) {
        return neighbours.get(i);
    }

    @Override
    public void addNeighbours(List<Vertex<E>> vs) {
        for(Vertex<E> v: vs){
            addNeighbour(v);
        }
    }

    @Override
    public void addSymmetricNeighbours(List<Vertex<E>> vs) {
        for(Vertex<E> v: vs){
            addSymmetricNeighbour(v);
        }
    }

    @Override
    public void addNeighbour(Vertex<E> v) {
        neighbours.add(v);
        grade++;
        ((MyVertex)v).incrementGrade();
    }

    @Override
    public void addSymmetricNeighbour(Vertex<E> v) {
        addNeighbour(v);
        v.addNeighbour(this);
    }

    public void incrementGrade(){
        grade++;
    }
    @Override
    public int grade() {
        return grade;
    }
    
    public void removeNeighbour(Vertex<E> v){
        neighbours.remove(v);
        grade--;
    }
    
    public void incrementaIngrado(){
        ingrade++;
    }
    
    public void incrementaExgrado(){
        exgrade++;
    }
        
}
